<template>
	<view>
<!-- 		<view v-if="!$isIos()" style="width: 100%;height: 44px;background-color: #FF1542;"></view>
		<uni-nav-bar color="#fff" backgroundColor="#fff" :border="false" >
			<block v-slot:left>
				<uni-icons class="rr-icons" color="#000" type="back" @click="goURls()" size="25"></uni-icons>
			</block>
			<view style="width: 100%;text-align: center;">
				<text style="font-size: 16px;color: #000;font-weight: 700;line-height: 44px;">公告</text>
			</view>
		</uni-nav-bar> -->
		<view class="notices">
			<!-- <scroll-view :style="{height: data.screenWith + 'px'}" scroll-y @scrolltolower='scrolltolower'> -->
      <empty v-if="!data.list"></empty>
				<view class="noticelist" v-for="(lin,index) in data.list" :key="index">
					<text class="titles">{{lin.title}}</text>
					<text class="contents">{{lin.content}}</text>
					<view class="parens">
						<text>发布人：</text>
						<text>{{lin.publisher}}</text>
					</view>
					<view class="parenDate">
						<text>发布时间：</text>
            <uni-dateformat :date="lin.CreatedAt"></uni-dateformat>
<!--						<text>{{lin.CreatedAt}}</text>-->
					</view>
				</view>
			<!-- </scroll-view> -->
		</view>
	</view>
</template>

<script setup>
	import {ref,reactive,getCurrentInstance} from "vue";
	import {onLoad,onShow} from "@dcloudio/uni-app";
  import empty from "@/components/empty.vue";
	const {proxy} = getCurrentInstance();
	const data = reactive({
		list:[],
		page:0,
		pages:1,
		size:10,
		screenWith:'',		//屏幕高度
	})
	onLoad((option)=>{
		data.list=proxy.$store.state.data
		getdata()
	})
	onShow(()=>{
		// 业务逻辑
		uni.getSystemInfo({
		    success: function (res) {
				if(res.platform == 'ios'){
					data.screenWith = res.windowHeight-94
				}else{
					data.screenWith = res.windowHeight-138
				}
		    }
		});
	})
	//滑动到底部/做上拉加载
	const scrolltolower=()=> {
		// getdata()
	}
	function getdata(){
		proxy.$request({
			url: `api/index/`,
			method: 'GET',
			success(res) {
				if(res.errno==0){
					data.list = res.data.notice
				}
			}
		})
	}
	function goURls(){
		uni.navigateBack()
	}
</script>

<style lang="scss" scoped>
	page{
		background-color:#f5f5f5;
	}
	.notices{
		padding: 10px;
		.noticelist{
			background-color: #fff;
			padding: 15px 10px;
			display: flex;
			flex-direction: column;
			border-radius: 20upx;
			margin-top: 20upx;
			.titles{
				font-weight: 700;
				font-size: 30upx;
			}
			.contents{
				font-size: 28upx;
				color: #7b7b7b;
				letter-spacing: 1px;
			}
			.parens{
				width: 100%;
				text-align: right;
				text{
					font-size: 14px;
					color: #333;
				}
			}
			.parenDate{
				width: 100%;
				text-align: right;
				text{
					font-size: 12px;
					color: #909399;
				}
			}
		}
	}
</style>
